﻿@*密码文本框*@

<label>密码：</label>

<input type="@(_showPassword?"text":"password")" @bind="Password" @oninput="Change" />

<button class="btn btn-primary btn-sm @(_showPassword?"active":"")" 
        @onclick="@(e=>_showPassword=!_showPassword)">
    @if (_showPassword)
    {
        <text>隐藏</text>
    }
    else
    {
        <text>显示</text>
    }
</button>

@code{
    bool _showPassword;

    [Parameter]public string? Password { get; set; }    
    [Parameter]public EventCallback<string?> PasswordChanged { get; set; }

    Task Change(ChangeEventArgs e)
    {
        if(e.Value is null)
        {
            return Task.CompletedTask;
        }
        return PasswordChanged.InvokeAsync(e.Value?.ToString());
    }
}